<html>
<head><meta charset="utf-8"><title>automatically adding a trait impl · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html">automatically adding a trait impl</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="192590318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192590318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192590318">(Apr 01 2020 at 20:43)</a>:</h4>
<p>Currently working on <a href="https://github.com/rust-lang/rust/issues/70509" title="https://github.com/rust-lang/rust/issues/70509">https://github.com/rust-lang/rust/issues/70509</a>.</p>
<p>I have added a new <code>lang_item</code> and updated <code>libcore</code>. <br>
I now want to add a correct impl of  <code>DiscriminantKind</code> to every type. I am stuck here. I tried looking how sized bounds are handled which I still don't fully understand.</p>
<p>What would the best way to automatically add an impl during compilation?</p>



<a name="192590589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192590589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192590589">(Apr 01 2020 at 20:45)</a>:</h4>
<p>uhhhh</p>



<a name="192590617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192590617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192590617">(Apr 01 2020 at 20:45)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> look at how <code>fn</code> types implement<code>FnOnce</code> automatically</p>



<a name="192590634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192590634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192590634">(Apr 01 2020 at 20:46)</a>:</h4>
<p>I <em>believe</em> that's in the compiler</p>



<a name="192590694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192590694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192590694">(Apr 01 2020 at 20:46)</a>:</h4>
<p><code>ty::FnPtr</code> in <code>select.rs</code> and <code>project.rs</code> I guess</p>



<a name="192590714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192590714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192590714">(Apr 01 2020 at 20:46)</a>:</h4>
<p>/me will look into it. Thanks</p>



<a name="192590775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192590775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192590775">(Apr 01 2020 at 20:46)</a>:</h4>
<p><code>project.rs</code> will likely mention a <code>Vtable::</code> variant that <code>select.rs</code> creates, if I had to guess</p>



<a name="192590798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192590798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192590798">(Apr 01 2020 at 20:47)</a>:</h4>
<p>(<code>Vtable</code> is a really misleading name for  "user or built-in impl")</p>



<a name="192597656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192597656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192597656">(Apr 01 2020 at 21:53)</a>:</h4>
<p>Will be harder as expected as there is no other builtin impl with associated types. Will look into this further tomorrow</p>



<a name="192597905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192597905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192597905">(Apr 01 2020 at 21:56)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> this would suggest there is <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_trait_selection/traits/project.rs#L1289-L1293" title="https://github.com/rust-lang/rust/blob/master/src/librustc_trait_selection/traits/project.rs#L1289-L1293">https://github.com/rust-lang/rust/blob/master/src/librustc_trait_selection/traits/project.rs#L1289-L1293</a></p>



<a name="192597934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192597934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192597934">(Apr 01 2020 at 21:56)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_trait_selection/traits/project.rs#L1354-L1358" title="https://github.com/rust-lang/rust/blob/master/src/librustc_trait_selection/traits/project.rs#L1354-L1358">https://github.com/rust-lang/rust/blob/master/src/librustc_trait_selection/traits/project.rs#L1354-L1358</a></p>



<a name="192597944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192597944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192597944">(Apr 01 2020 at 21:57)</a>:</h4>
<p>this is for the associated type <code>"Output"</code></p>



<a name="192597993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192597993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192597993">(Apr 01 2020 at 21:57)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> btw we still have <code>ty::ProjectionTy::from_ref_and_name</code> which finds associated types by name, instead of making them lang items (or just taking the first associated type inside the trait)</p>



<a name="192605134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192605134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192605134">(Apr 01 2020 at 23:25)</a>:</h4>
<p>Ah yeah. That slipped my mind. I'll open an issue so I don't forget</p>



<a name="192721722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192721722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192721722">(Apr 02 2020 at 20:29)</a>:</h4>
<p>It finally compiles <span aria-label="party ball" class="emoji emoji-1f38a" role="img" title="party ball">:party_ball:</span> fk yes</p>



<a name="192783370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192783370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192783370">(Apr 03 2020 at 10:17)</a>:</h4>
<p>I am once again stuck. I now correctly generate an impl on the fly in case the type is specific enough.<br>
My behavior for unresolved types is still wrong though. When using e.g. <code>&lt;T as DiscriminantKind&gt;::Discriminant</code><br>
I don't know the type of <code>Discriminant</code> yet.</p>
<p>I tried 2 approaches: always adding a candidate during selection and returning the projection <code>&lt;T as DiscriminantKind&gt;::Discriminant</code> in <code>project.rs</code> if the assoc type is not yet known. This cases a cycle.</p>
<p>check during selections if the type can already be known and only add a candidate in this case, this is similar to what is done for <code>Sized</code>.<br>
Which cases the error</p>
<div class="codehilite"><pre><span></span>error[E0277]: the trait bound `T: marker::DiscriminantKind` is not satisfied
   --&gt; src/libcore/mem/mod.rs:935:28
    |
935 | pub struct Discriminant&lt;T&gt;(&lt;T as DiscriminantKind&gt;::Discriminant);
    |
</pre></div>


<p>How can I express that a trait is implemented for <code>T</code> without actually caring about any specific impl</p>



<a name="192783828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192783828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192783828">(Apr 03 2020 at 10:21)</a>:</h4>
<p>fascinating conondrum</p>



<a name="192783845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192783845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192783845">(Apr 03 2020 at 10:21)</a>:</h4>
<p>you might need to rely on specialization</p>



<a name="192783914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192783914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192783914">(Apr 03 2020 at 10:22)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">DiscriminantKind</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">default</span> <span class="k">type</span><span class="w"> </span><span class="n">Discriminant</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="192784013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192784013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192784013">(Apr 03 2020 at 10:23)</a>:</h4>
<p>and only use the builtin one for <code>enum</code>s and generators</p>



<a name="192784094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192784094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192784094">(Apr 03 2020 at 10:24)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span> I'm not sure using specialization like this is the best thing to do</p>



<a name="192950920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192950920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192950920">(Apr 05 2020 at 09:42)</a>:</h4>
<p>Big brain move to both use specialization and still forbid impls of the new lang item. <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> </p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">DiscriminantKind</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Discriminant</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">DiscriminantKind</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="k">default</span> <span class="k">type</span><span class="w"> </span><span class="n">Discriminant</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">!</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">ActualDiscriminantKind</span><span class="o">&gt;</span><span class="w"> </span><span class="n">DiscriminantKind</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Discriminant</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">T</span>::<span class="n">ActualDiscriminant</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;actual_discriminant_kind&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">trait</span><span class="w"> </span><span class="n">ActualDiscriminantKind</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">ActualDiscriminant</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="192951314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951314">(Apr 05 2020 at 09:53)</a>:</h4>
<p>but you don't need to expose the trait at all</p>



<a name="192951318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951318">(Apr 05 2020 at 09:53)</a>:</h4>
<p>it can be both a lang item and fully private</p>



<a name="192951319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951319">(Apr 05 2020 at 09:53)</a>:</h4>
<p>(this is how <code>Freeze</code> works IIRC)</p>



<a name="192951371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951371">(Apr 05 2020 at 09:54)</a>:</h4>
<p>I wonder if using specialization default + builtin implementation will break</p>



<a name="192951374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951374">(Apr 05 2020 at 09:54)</a>:</h4>
<p>because the builtin thing is not in the specialization graph :P</p>



<a name="192951382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951382">(Apr 05 2020 at 09:55)</a>:</h4>
<p>probably not, the compiler will just handle it separately</p>



<a name="192951397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951397">(Apr 05 2020 at 09:55)</a>:</h4>
<blockquote>
<p>probably not, the compiler will just handle it separately</p>
</blockquote>
<p>I hope so <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> <br>
I guess it should work. As this is the same as specializing over <code>Sized</code></p>



<a name="192951398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951398">(Apr 05 2020 at 09:55)</a>:</h4>
<p>the specialization graph is for moving towards the trait (in the "less specialized" direction), not the other way around, so I think we're fine</p>



<a name="192951442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192951442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192951442">(Apr 05 2020 at 09:56)</a>:</h4>
<p>anyway there's a reason I want <span class="user-mention" data-user-id="116009">@nikomatsakis</span> to review your PR :P</p>



<a name="192955377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955377">(Apr 05 2020 at 11:44)</a>:</h4>
<p>Do we have const trait methods on nightly yet?</p>
<p>I shot myself in the knee by making mem::discriminant unstabily const... Or I just remove the const attribute for now <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="192955465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955465">(Apr 05 2020 at 11:46)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> why? the intrinsic should still be const</p>



<a name="192955472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955472">(Apr 05 2020 at 11:47)</a>:</h4>
<p>always use the intrinsic, the trait is there just to get the right type for the intrinsic</p>



<a name="192955643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955643">(Apr 05 2020 at 11:51)</a>:</h4>
<p>I use the setup from above.</p>
<p>While the compiler knows that <code>DiscriminantKind</code> is implemented for all <code>T</code>. It does not know this for <code>ActualDiscriminantType</code>.<br>
As I have to check that <code>intrinsics::discriminant_value</code> has the correct signature, the used trait must be a lang item.<br>
I don't want to add 2 new lang items though. To solve this I restricted the intrinsic to <code>ActualDiscriminantType</code> and added a <code>discriminant_value</code> method to <code>DiscriminantKind</code> which calls <code>intrinsics::discriminant_value</code> in the specialized impl and is irrelevant otherwise.</p>



<a name="192955652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955652">(Apr 05 2020 at 11:51)</a>:</h4>
<p>you should only use one trait</p>



<a name="192955710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955710">(Apr 05 2020 at 11:52)</a>:</h4>
<p>the two-trait system is funny but it should <em>really</em> not be needed</p>



<a name="192955715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955715">(Apr 05 2020 at 11:52)</a>:</h4>
<p>the intrinsic can already handle all the situations anyway</p>



<a name="192955722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955722">(Apr 05 2020 at 11:52)</a>:</h4>
<p>it's just the trait that you need to make work</p>



<a name="192955725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955725">(Apr 05 2020 at 11:52)</a>:</h4>
<p>and like I said, you can have it be a lang item and completely private</p>



<a name="192955735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955735">(Apr 05 2020 at 11:53)</a>:</h4>
<p>you can even import the intrinsic in a module other than <code>core::intrinsics</code></p>



<a name="192955743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955743">(Apr 05 2020 at 11:53)</a>:</h4>
<p>you can even import the intrinsic inside <code>mem::discriminant</code> :P (and this is what some other parts of <code>libcore</code> do)</p>



<a name="192955900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192955900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192955900">(Apr 05 2020 at 11:57)</a>:</h4>
<blockquote>
<p>the two-trait system is funny but it should really not be needed</p>
</blockquote>
<p>But this is such a ****ing beauty. I will never again have the chance to make a mess like this <span aria-label="cry" class="emoji emoji-1f622" role="img" title="cry">:cry:</span> </p>
<p>By only having 1 trait I can't check that there aren't any unsound impls. Which is unfortunate, but probably ok as long as <code>DiscriminantKind</code> is private. Will use a one-trait approach for now <span aria-label="unicorn" class="emoji emoji-1f984" role="img" title="unicorn">:unicorn:</span></p>



<a name="192958005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192958005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192958005">(Apr 05 2020 at 12:50)</a>:</h4>
<p>they don't have to be unsound, just assert in <code>rustc_codegen_llvm</code> or wherever <code>discriminant_value</code> is implemented, that the type matches</p>



<a name="192958010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192958010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192958010">(Apr 05 2020 at 12:50)</a>:</h4>
<p>then not even libcore could add a bad impl</p>



<a name="192964953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192964953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192964953">(Apr 05 2020 at 15:41)</a>:</h4>
<p>eyyy, everything but codegen works now afaict <span aria-label="muscle" class="emoji emoji-1f4aa" role="img" title="muscle">:muscle:</span></p>



<a name="192968488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192968488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192968488">(Apr 05 2020 at 17:13)</a>:</h4>
<p>is there a way to only check stage 2 using stage 1?</p>



<a name="192969396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192969396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192969396">(Apr 05 2020 at 17:36)</a>:</h4>
<p>you mean <code>./x.py check</code> but using the compiler you built?</p>



<a name="192969397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192969397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192969397">(Apr 05 2020 at 17:36)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116122">@simulacrum</span></p>



<a name="192969498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192969498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192969498">(Apr 05 2020 at 17:38)</a>:</h4>
<p>Not easily, check is hard coded for stage 0</p>



<a name="192971946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192971946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192971946">(Apr 05 2020 at 18:40)</a>:</h4>
<p>seems like I just have to get the change right on the first try then <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="192972570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192972570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192972570">(Apr 05 2020 at 18:54)</a>:</h4>
<p>meh</p>
<div class="codehilite"><pre><span></span><span class="n">error</span><span class="p">[</span><span class="n">E0599</span><span class="p">]</span>: <span class="nc">no</span><span class="w"> </span><span class="n">method</span><span class="w"> </span><span class="n">named</span><span class="w"> </span><span class="err">`</span><span class="n">unwrap</span><span class="err">`</span><span class="w"> </span><span class="n">found</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">enum</span> <span class="err">`</span><span class="n">std</span>::<span class="n">result</span>::<span class="nb">Result</span><span class="o">&lt;</span><span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="o">&lt;</span><span class="kt">usize</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">std</span>::<span class="n">convert</span>::<span class="n">TryFrom</span><span class="o">&lt;&lt;&lt;</span><span class="n">T</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">ty</span>::<span class="n">codec</span>::<span class="n">EncodableWithShorthand</span><span class="o">&gt;</span>::<span class="n">Variant</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">std</span>::<span class="n">marker</span>::<span class="n">DiscriminantKind</span><span class="o">&gt;</span>::<span class="n">Discriminant</span><span class="o">&gt;&gt;</span>::<span class="n">Error</span><span class="o">&gt;</span><span class="err">`</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="n">current</span><span class="w"> </span><span class="n">scope</span><span class="w"></span>
<span class="w">  </span><span class="o">-</span>-&gt; <span class="nc">src</span><span class="o">/</span><span class="n">librustc_middle</span><span class="o">/</span><span class="n">ty</span><span class="o">/</span><span class="n">codec</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">82</span>:<span class="mi">43</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="mi">82</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="kt">usize</span>::<span class="n">try_from</span><span class="p">(</span><span class="n">discriminant</span><span class="p">).</span><span class="n">unwrap</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">SHORTHAND_OFFSET</span><span class="p">);</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">                                           </span><span class="o">^^^^^^</span><span class="w"> </span><span class="n">method</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">found</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="err">`</span><span class="n">std</span>::<span class="n">result</span>::<span class="nb">Result</span><span class="o">&lt;</span><span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="o">&lt;</span><span class="kt">usize</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">std</span>::<span class="n">convert</span>::<span class="n">TryFrom</span><span class="o">&lt;&lt;&lt;</span><span class="n">T</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">ty</span>::<span class="n">codec</span>::<span class="n">EncodableWithShorthand</span><span class="o">&gt;</span>::<span class="n">Variant</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">std</span>::<span class="n">marker</span>::<span class="n">DiscriminantKind</span><span class="o">&gt;</span>::<span class="n">Discriminant</span><span class="o">&gt;&gt;</span>::<span class="n">Error</span><span class="o">&gt;</span><span class="err">`</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="w">   </span><span class="o">=</span><span class="w"> </span><span class="n">note</span>: <span class="nc">the</span><span class="w"> </span><span class="n">method</span><span class="w"> </span><span class="err">`</span><span class="n">unwrap</span><span class="err">`</span><span class="w"> </span><span class="n">exists</span><span class="w"> </span><span class="n">but</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="n">following</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">bounds</span><span class="w"> </span><span class="n">were</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">satisfied</span>:
           <span class="err">`</span><span class="o">&lt;</span><span class="kt">usize</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">std</span>::<span class="n">convert</span>::<span class="n">TryFrom</span><span class="o">&lt;&lt;&lt;</span><span class="n">T</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">ty</span>::<span class="n">codec</span>::<span class="n">EncodableWithShorthand</span><span class="o">&gt;</span>::<span class="n">Variant</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">std</span>::<span class="n">marker</span>::<span class="n">DiscriminantKind</span><span class="o">&gt;</span>::<span class="n">Discriminant</span><span class="o">&gt;&gt;</span>::<span class="n">Error</span>: <span class="nc">std</span>::<span class="n">fmt</span>::<span class="n">Debug</span><span class="err">`</span><span class="w"></span>

<span class="n">error</span>: <span class="nc">aborting</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="n">previous</span><span class="w"> </span><span class="n">error</span><span class="w"></span>
</pre></div>



<a name="192974568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974568">(Apr 05 2020 at 19:42)</a>:</h4>
<p>haha</p>



<a name="192974572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974572">(Apr 05 2020 at 19:42)</a>:</h4>
<p>that method was abusing <code>discriminant_value</code></p>



<a name="192974600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974600">(Apr 05 2020 at 19:43)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> you should add a bound to that function, e.g. <code>T: Discriminant&lt;DiscriminantKind = isize&gt;</code> (if the trait is public), or just define a local copy of the intrinsic that just returns <code>isize</code></p>



<a name="192974609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974609">(Apr 05 2020 at 19:43)</a>:</h4>
<p>(since that's the default discriminant type)</p>



<a name="192974761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974761">(Apr 05 2020 at 19:47)</a>:</h4>
<p>I fixed this without restricting <code>DiscriminantKind</code> for now. <a href="https://github.com/rust-lang/rust/pull/70705/files#diff-8fbc542a08b9274446b2fbf02bd610b2R80-R87" title="https://github.com/rust-lang/rust/pull/70705/files#diff-8fbc542a08b9274446b2fbf02bd610b2R80-R87">https://github.com/rust-lang/rust/pull/70705/files#diff-8fbc542a08b9274446b2fbf02bd610b2R80-R87</a></p>
<p>I am currently considering if changing the discriminant to <code>i8</code>/<code>u8</code> where possible is worth the effort. Don't know if there is any case were the size of <code>mem::Discriminant</code> actually matters though <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="192974860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974860">(Apr 05 2020 at 19:49)</a>:</h4>
<p>no, please leave enums unnanotated</p>



<a name="192974914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974914">(Apr 05 2020 at 19:50)</a>:</h4>
<p><code>#[repr(u8)]</code> <em>disables all layout optimizations</em></p>



<a name="192974920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974920">(Apr 05 2020 at 19:50)</a>:</h4>
<p>and the actual tag in memory is byte-sized for most <code>enum</code>s anyway</p>



<a name="192974955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974955">(Apr 05 2020 at 19:51)</a>:</h4>
<blockquote>
<p>#[repr(u8)] disables all layout optimizations</p>
</blockquote>
<p>no no no</p>
<p>I mean inside of the compiler. I don't want to tag all enums. I want to change <code>DiscriminantKind::Discriminant</code> for <code>enum Meh { A, B }</code> to <code>u8</code> automatically</p>



<a name="192974960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974960">(Apr 05 2020 at 19:51)</a>:</h4>
<p>I left a comment</p>



<a name="192974998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192974998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192974998">(Apr 05 2020 at 19:52)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> ah that's unworkable</p>



<a name="192975015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192975015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192975015">(Apr 05 2020 at 19:52)</a>:</h4>
<p>?</p>



<a name="192975022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192975022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192975022">(Apr 05 2020 at 19:52)</a>:</h4>
<p>the discriminant type <em>needs to be</em> the same as specified on the <code>enum</code> (or the default, <code>isize</code>)</p>



<a name="192975026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192975026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192975026">(Apr 05 2020 at 19:52)</a>:</h4>
<p>otherwise, some things may stop working as expected</p>



<a name="192975042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192975042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192975042">(Apr 05 2020 at 19:53)</a>:</h4>
<p>that's the type that explicit discriminant values are type-checked against</p>



<a name="192975050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192975050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192975050">(Apr 05 2020 at 19:53)</a>:</h4>
<p>it's not the same as the tag the compiler might <em>encode</em> that discriminant as</p>



<a name="192975385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192975385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192975385">(Apr 05 2020 at 20:00)</a>:</h4>
<p>Still think that we could use some kind of special case for simple cases <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> <br>
It probably just isn't worth it</p>



<a name="192976866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192976866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192976866">(Apr 05 2020 at 20:35)</a>:</h4>
<p>it's better to be consistent IMO</p>



<a name="192977016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977016">(Apr 05 2020 at 20:38)</a>:</h4>
<p>DiscriminantKind should never be used directly though. I am somewhat  in favor of just replacing the current usage in the compiler with a manually implemented function.</p>



<a name="192977055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977055">(Apr 05 2020 at 20:39)</a>:</h4>
<p>An unobservable inconsistency is fairly irrelevant tbh <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="192977114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977114">(Apr 05 2020 at 20:41)</a>:</h4>
<p>you mean with a separate import of the intrinsic?</p>



<a name="192977283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977283">(Apr 05 2020 at 20:45)</a>:</h4>
<blockquote>
<p>you mean with a separate import of the intrinsic?</p>
</blockquote>
<p>While this might actually work, imo this is even worse.</p>
<p>My approach would be the following even if it is not 100 % dry.</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="w"> </span><span class="n">TyKind</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="k">fn</span> <span class="nf">variant_id</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">u64</span> <span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">match</span><span class="w"> </span><span class="bp">self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">TyKind</span>::<span class="n">Bool</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="n">TyKind</span>::<span class="n">Int</span><span class="p">(</span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"></span>
<span class="w">           </span><span class="c1">// ...</span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="192977289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977289">(Apr 05 2020 at 20:45)</a>:</h4>
<p>ah no please don't do that</p>



<a name="192977296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977296">(Apr 05 2020 at 20:45)</a>:</h4>
<p>the reason we use <code>discriminant_value</code> is because that's what <code>libserialize</code> encodes (or, well, it's less likely to get out of sync)</p>



<a name="192977340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977340">(Apr 05 2020 at 20:46)</a>:</h4>
<p>I guess we could abuse serialization and get it that way heh</p>



<a name="192977364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977364">(Apr 05 2020 at 20:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/automatically.20adding.20a.20trait.20impl/near/192977296" title="#narrow/stream/182449-t-compiler.2Fhelp/topic/automatically.20adding.20a.20trait.20impl/near/192977296">said</a>:</p>
<blockquote>
<p>the reason we use <code>discriminant_value</code> is because that's what <code>libserialize</code> encodes (or, well, it's less likely to get out of sync)</p>
</blockquote>
<p>that makes the current state actually worse IMO <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="192977375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977375">(Apr 05 2020 at 20:47)</a>:</h4>
<p>we're basically checking that we can make up variant indices that <em>would not</em> be valid discriminants of the <code>enum</code></p>



<a name="192977383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977383">(Apr 05 2020 at 20:47)</a>:</h4>
<p>so please try to avoid changing it as much as possible</p>



<a name="192977388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977388">(Apr 05 2020 at 20:47)</a>:</h4>
<p>any change there would require far more intensive perf-testing</p>



<a name="192977391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192977391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192977391">(Apr 05 2020 at 20:48)</a>:</h4>
<p>and care</p>



<a name="192978685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/192978685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#192978685">(Apr 05 2020 at 21:17)</a>:</h4>
<p>(deleted)</p>



<a name="193722404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193722404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193722404">(Apr 12 2020 at 17:42)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span>  do you have an opinion on <a href="https://github.com/rust-lang/rust/pull/70705#discussion_r403752647" title="https://github.com/rust-lang/rust/pull/70705#discussion_r403752647">https://github.com/rust-lang/rust/pull/70705#discussion_r403752647</a> ?</p>



<a name="193722561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193722561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193722561">(Apr 12 2020 at 17:47)</a>:</h4>
<p>The PR still slightly improves perf afaict, even while using <code>TryFrom</code> there. (mostly because <code>Eq</code> for enums now uses <code>i32</code>instead of <code>u64</code>)</p>



<a name="193724221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193724221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193724221">(Apr 12 2020 at 18:29)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> why do you say <code>i32</code>?</p>



<a name="193724231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193724231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193724231">(Apr 12 2020 at 18:29)</a>:</h4>
<p><code>enum</code> discriminants default to <code>isize</code> by default which is <code>i64</code> on the x64 linux that perf runs on</p>



<a name="193724241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193724241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193724241">(Apr 12 2020 at 18:30)</a>:</h4>
<p>the only thing that uses <code>i32</code> by default is generators and maybe <code>#[repr(C)]</code> <code>enum</code>s?</p>



<a name="193724293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193724293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193724293">(Apr 12 2020 at 18:30)</a>:</h4>
<p>jup, was wrong. Then I don't know why there are minimal perf improvements</p>



<a name="193724301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193724301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193724301">(Apr 12 2020 at 18:30)</a>:</h4>
<p>there aren't :)</p>



<a name="193724304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193724304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193724304">(Apr 12 2020 at 18:30)</a>:</h4>
<p>that's just noise</p>



<a name="193724379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193724379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193724379">(Apr 12 2020 at 18:32)</a>:</h4>
<p>(deleted)</p>



<a name="193724571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193724571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193724571">(Apr 12 2020 at 18:37)</a>:</h4>
<p>I really want us to fix perf to have even less noise</p>



<a name="193730168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193730168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193730168">(Apr 12 2020 at 21:07)</a>:</h4>
<div class="codehilite"><pre><span></span>error[E0277]: `&lt;&lt;&lt;T as ty::codec::EncodableWithShorthand&gt;::Variant as std::marker::DiscriminantKind&gt;::Discriminant as std::convert::TryFrom&lt;usize&gt;&gt;::Error` doesn&#39;t implement `std::fmt::Debug`
  --&gt; src/librustc_middle/ty/codec.rs:81:56
   |
65 |     &lt;T::Variant as DiscriminantKind&gt;::Discriminant: Ord + TryFrom&lt;usize&gt;,
   |                                                                          - help: consider further restricting the associated type: `, &lt;&lt;&lt;T as ty::codec::EncodableWithShorthand&gt;::Variant as std::marker::DiscriminantKind&gt;::Discriminant as std::convert::TryFrom&lt;usize&gt;&gt;::Error: std::fmt::Debug`
</pre></div>



<a name="193730377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193730377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193730377">(Apr 12 2020 at 21:12)</a>:</h4>
<p>lol</p>



<a name="193730390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193730390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193730390">(Apr 12 2020 at 21:13)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> replace <code>.unwrap()</code> with <code>.ok().unwrap()</code></p>



<a name="193730399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193730399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193730399">(Apr 12 2020 at 21:13)</a>:</h4>
<p>replaced it with <code>unwrap_or_else(|_| unreachable())</code>. Your version is better though <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="193768723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193768723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193768723">(Apr 13 2020 at 12:52)</a>:</h4>
<p>@eddyb <a href="https://github.com/rust-lang/rust/pull/70705#issuecomment-612884955" title="https://github.com/rust-lang/rust/pull/70705#issuecomment-612884955">https://github.com/rust-lang/rust/pull/70705#issuecomment-612884955</a> implemented some of your feedback.</p>



<a name="193772715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193772715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193772715">(Apr 13 2020 at 13:42)</a>:</h4>
<p>btw it doesn't ping me if you don't press TAB</p>



<a name="193772725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193772725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193772725">(Apr 13 2020 at 13:42)</a>:</h4>
<p>i.e. it has to look like <code>@**eddyb**</code> before you send it</p>



<a name="193783247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193783247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193783247">(Apr 13 2020 at 15:27)</a>:</h4>
<p>you're going to read it anyways <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="193784193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193784193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193784193">(Apr 13 2020 at 15:36)</a>:</h4>
<p>yeah it's just a difference of timing</p>



<a name="193793959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193793959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193793959">(Apr 13 2020 at 17:05)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> Thank you for <a href="https://github.com/rust-lang/rust/pull/70705#discussion_r407504945" title="https://github.com/rust-lang/rust/pull/70705#discussion_r407504945">https://github.com/rust-lang/rust/pull/70705#discussion_r407504945</a> <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span></p>



<a name="193795337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193795337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193795337">(Apr 13 2020 at 17:17)</a>:</h4>
<p>omg did it work :D?</p>



<a name="193795577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193795577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193795577">(Apr 13 2020 at 17:19)</a>:</h4>
<p>jup</p>



<a name="193795694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193795694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193795694">(Apr 13 2020 at 17:20)</a>:</h4>
<p>phew, glad to not need specialization</p>



<a name="193796051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193796051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193796051">(Apr 13 2020 at 17:22)</a>:</h4>
<p>btw you have an accidental submodule addition</p>



<a name="193796392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193796392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193796392">(Apr 13 2020 at 17:24)</a>:</h4>
<p><span aria-label="dolphin" class="emoji emoji-1f42c" role="img" title="dolphin">:dolphin:</span>  do you know how to cleanly remove this? The last time I tried I just ended up nuking my local rust repo</p>



<a name="193796732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193796732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193796732">(Apr 13 2020 at 17:27)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> generally I use selective addition, either via <code>git gui</code> or IDE integration (I don't use commands like <code>git add</code>), so I just never add a submodule change to a commit</p>



<a name="193796748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193796748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193796748">(Apr 13 2020 at 17:27)</a>:</h4>
<p>now, this is readding a whole submodule, not just committing a change to it</p>



<a name="193796777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193796777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193796777">(Apr 13 2020 at 17:27)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> the first step is to find which commit it's in, and then you can take it out just like any unwanted file change</p>



<a name="193796855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193796855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193796855">(Apr 13 2020 at 17:28)</a>:</h4>
<p>the important thing is to use <code>git gui</code> to steal it from a commit, that's the only intuitive way I can think of</p>



<a name="193797029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797029">(Apr 13 2020 at 17:29)</a>:</h4>
<p>okay so it's in this commit <a href="https://github.com/rust-lang/rust/pull/70705/commits/22de130b956498a9d8dae9e237d812b116044065" title="https://github.com/rust-lang/rust/pull/70705/commits/22de130b956498a9d8dae9e237d812b116044065">https://github.com/rust-lang/rust/pull/70705/commits/22de130b956498a9d8dae9e237d812b116044065</a></p>



<a name="193797098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797098">(Apr 13 2020 at 17:30)</a>:</h4>
<p>It's fixed <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="193797136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797136">(Apr 13 2020 at 17:30)</a>:</h4>
<p>did you use a rebase, or something else ?</p>



<a name="193797174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797174">(Apr 13 2020 at 17:30)</a>:</h4>
<p>apparently <code>git rm path/to/file</code> just works</p>



<a name="193797189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797189">(Apr 13 2020 at 17:30)</a>:</h4>
<p>and then an ordinary rebase</p>



<a name="193797246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797246">(Apr 13 2020 at 17:31)</a>:</h4>
<p>well, it's not in the commit which had it, so its' fine now</p>



<a name="193797475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797475">(Apr 13 2020 at 17:33)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="193797627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797627">(Apr 13 2020 at 17:34)</a>:</h4>
<p>Thank you for guiding me through all of this!</p>



<a name="193797818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797818">(Apr 13 2020 at 17:36)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> so <span class="user-mention" data-user-id="133247">@bjorn3</span> left a comment, do you want to address it now, or...?</p>



<a name="193797842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797842">(Apr 13 2020 at 17:36)</a>:</h4>
<p>like I want to do a try build but I just saw that comment just show up</p>



<a name="193797947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797947">(Apr 13 2020 at 17:37)</a>:</h4>
<p>idk. I intentionally used <code>mem::discriminant</code> here, as I meant the method, not the type</p>



<a name="193797974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193797974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193797974">(Apr 13 2020 at 17:37)</a>:</h4>
<p>okay, you can leave a comment about that</p>



<a name="193799150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193799150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193799150">(Apr 13 2020 at 17:47)</a>:</h4>
<p>Whitespace <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> </p>
<div class="codehilite"><pre><span></span>---- [ui] ui/enum-discriminant/forbidden-discriminant-kind-impl.rs stdout ----
diff of stderr:

1   error[E0322]: explicit impls for the `DiscriminantKind` trait are not permitted
2     --&gt; $DIR/forbidden-discriminant-kind-impl.rs:9:1
3      |
-   LL | impl DiscriminantKind for NewType {
+   LL | impl DiscriminantKind for NewType {
5      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of &#39;DiscriminantKind&#39; not allowed
6
7   error: aborting due to previous error
</pre></div>


<p>Seems like you have to restart bors</p>



<a name="193800246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193800246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193800246">(Apr 13 2020 at 17:57)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> try builds don't run tests :P</p>



<a name="193800358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193800358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193800358">(Apr 13 2020 at 17:58)</a>:</h4>
<p>I already rebased, does that stop the build?</p>



<a name="193800432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193800432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193800432">(Apr 13 2020 at 17:58)</a>:</h4>
<p>nope</p>



<a name="193800458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193800458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193800458">(Apr 13 2020 at 17:59)</a>:</h4>
<p>great <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="193800476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193800476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193800476">(Apr 13 2020 at 17:59)</a>:</h4>
<p>but it's a bad idea because it breaks feedback from the bot once it's done, IIRC :P</p>



<a name="193800553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193800553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193800553">(Apr 13 2020 at 17:59)</a>:</h4>
<p>perf and crater will still work AFAIK</p>



<a name="193800983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193800983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193800983">(Apr 13 2020 at 18:03)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> note the yellow circle next to <a href="https://github.com/rust-lang/rust/pull/70705#ref-commit-9b5b377" title="https://github.com/rust-lang/rust/pull/70705#ref-commit-9b5b377">https://github.com/rust-lang/rust/pull/70705#ref-commit-9b5b377</a></p>



<a name="193801006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/automatically%20adding%20a%20trait%20impl/near/193801006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/automatically.20adding.20a.20trait.20impl.html#193801006">(Apr 13 2020 at 18:03)</a>:</h4>
<p>so bors is still going</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>